package main

import (
	"fmt"
	"reflect"
)

func reflectValue(x interface{}) {
	// var num = x + 10 //invalid operation: x + 10 (mismatched types interface{} and int)

	//类型断言
	b, ok := x.(int) //.(type) 类型断言
	if ok {
		num := b + 10
		fmt.Println(num) //23
	}

	//反射实现
	v := reflect.ValueOf(x)
	/* 	var n = v + 12 //cannot convert 12 (untyped int constant) to type struct{typ_ *abi.Type; ptr unsafe.Pointer;
	   	fmt.Println(v) */
	//反射获取原始值
	var m = v.Int() + 10
	fmt.Println(m) //23

}

func main() {

	var a = 13

	reflectValue(a)

}
